package com.sooth.micro.business.function;

import com.sooth.common.core.exception.ServiceException;
import org.springframework.stereotype.Service;

@Service
public class DefaultValueFunctionFactory implements ValueFunctionFactory {
    private ValueFunction nowValueFunction = new NowValueFunction();
    private ValueFunction loginUserIdValueFunction = new LoginUserIdValueFunction();
    private ValueFunction snowFlakeValueFunction = new SnowFlakeValueFunction();

    @Override
    public Object getValue(String functionName) {
        switch (functionName) {
            case "now" -> {
                return nowValueFunction.getValue();
            }
            case "snowFlake" -> {
                return snowFlakeValueFunction.getValue();
            }
            case "loginUserId" -> {
                return loginUserIdValueFunction.getValue();
            }
            default -> throw new ServiceException("未识别的函数" + functionName);
        }
    }
}
